package com.behome.common.enums;

/**
 * FileTypeEnum 文件后缀类型
 *
 * @author bh_ljy
 * @version 2024/04/29 17:08
 **/
public enum FileTypeEnum {
    T01("JPG", "图片"),
    T02("PNG", "图片"),
    T03("MP3", "MP3"),
    T04("MP4", "MP4"),
    T05("TXT", "文字");
    private String code;
    private String value;

    // 构造方法
    FileTypeEnum(String code, String value) {
        this.code = code;
        this.value = value;
    }

    // 获取名字
    public static String getCode(String value) {
        for (FileTypeEnum c : FileTypeEnum.values()) {
            if (c.getValue().equals(value)) {
                return c.code;
            }
        }
        return "未知文件类型";
    }

    //获取ID
    public static String getValue(String code) {
        for (FileTypeEnum c : FileTypeEnum.values()) {
            if (c.getCode().equalsIgnoreCase(code)) {
                return c.value;
            }
        }
        return "未知文件类型";
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    // 覆盖方法
    @Override
    public String toString() {
        return this.value + "_" + this.code;
    }
}
